 #@layout()
 #define content()

<span class="layui-breadcrumb">
  <a href="/">首页</a>
  <a href="/admin/websiteContent"><cite>我的内容</cite></a>
</span>

<hr>


<div class="layui-field-box">
<form class="layui-form" action="/admin/user">
    <div class="layui-form-item">
    		<div class="layui-inline">
	      <label class="layui-form-label">搜索内容</label>
	      <div class="layui-input-inline">
	        <input type="text" name="searchContent" autocomplete="off" class="layui-input" placeholder="请输入内容搜索">
	      </div>
	    </div>
	    
	    <div class="layui-inline">
	      <label class="layui-form-label">状态</label>
	      <div class="layui-input-inline">
	      		#set(STATUS_MAP={})
	      		#set(STATUS_MAP["dicTypeCode"]="CMS_CONTENT_STATUS")
	      		#set(STATUS_MAP["name"]="status")
	      	   	#set(STATUS_MAP["id"]="status")
	        	   	#@dic_get_select(STATUS_MAP)
	      </div>
	    </div>
	    
	    <div class="layui-inline">
	      <label class="layui-form-label">模块</label>
	      <div class="layui-input-inline">
	      		#set(DIC_MAP={})
	      		#set(DIC_MAP["dicTypeCode"]="CMS_MODULE")
	      		#set(DIC_MAP["name"]="module")
	      	   	#set(DIC_MAP["id"]="module")
	        	   	#@dic_get_select(DIC_MAP)
	      </div>
	    </div>
	    
	    <button class="layui-btn" type="button" id="btnSearch">搜索</button>
	    <button class="layui-btn layui-btn-normal" type="reset" >重置</button>
	    
	</div>
</form>	    
</div>
  
<table class="layui-hide" id="dataTable"></table>

<script type="text/html" id="actionTpl">
  	<a href="javascript:doDetail('{{d.id}}');" class="layui-table-link" actionType="detail" actionId="{{d.id}}">详情</a>
  	<a href="javascript:doStartUsing('{{d.id}}');" class="layui-table-link" >启用</a>
  	<a href="javascript:doForbidden('{{d.id}}');" class="layui-table-link" >禁用</a>
  	<a href="javascript:doDelete('{{d.id}}');" class="layui-table-link" >删除</a>
</script>

#end

#define js()

<script>

layui.use('table', function() {
	
	var table = layui.table;
	table.render({
		elem : '#dataTable',
		url : '/admin/websiteContent/pagequery',
		cols : [ [
	      {field:'title', title: '标题'},
	      {field:'createTime', title: '创建时间', sort: true},
	      {field:'websiteColumnName', title: '所属栏目'},
	      {field:'module_dic', title: '所属模块'},
	      {field:'pv', title: '浏览量', sort: true},
	      {field:'status_dic', title: '状态'},
	      {templet:"#actionTpl",width:'200',title: '操作'}
		] ],
		page : true
	});
	
	$("#btnSearch").click(function(){
		
		var searchContent=$(":input[name='searchContent']").val();
		var status=$(":input[name='status']").val();
		var module=$(":input[name='module']").val();
		
		//执行重载
		table.reload('dataTable', {
			page : {
				curr : 1//重新从第 1 页开始
			},
			where : {
				searchContent:searchContent,
				status:status,
				module:module
			}
		});
		
	});

});


function doDetail(id){
	window.location.href="/admin/myWebsite/publish?websiteContentId="+id;
}

function doStartUsing(id) {
	layui.layer.confirm('确认启用么?', function(index) {
		$.ajax({
			type : 'get',
			url : '/admin/myWebsite/myWebsiteContent/startUsing',
			data : 'id=' + id,
			success : function(data) {
				layui.table.reload('dataTable');
			}
		});
		layui.layer.close(index);
	});
}

function doForbidden(id) {
	layui.layer.confirm('确认禁用么?', function(index) {
		$.ajax({
			type : 'get',
			url : '/admin/myWebsite/myWebsiteContent/forbidden',
			data : 'id=' + id,
			success : function(data) {
				layui.table.reload('dataTable');
			}
		});
		layui.layer.close(index);
	});
}

function doDelete(id){
	layui.layer.confirm('确认删除么?', function(index) {
		$.ajax({
			type : 'get',
			url : '/admin/myWebsite/myWebsiteContent/delete',
			data : 'id=' + id,
			success : function(data) {
				layui.table.reload('dataTable');
			}
		});
		layui.layer.close(index);
	});
}

</script>

#end


